<html>
<head>
	<meta charset="UTF-8">
	<title>Netty WebSocket 时间服务器</title>
</head>

<br>
<body>
	<script type="text/javascript">
		var socket ;
		if(!window.WebSocket){
			window.WebSocket = window.MozWebSocket;
		}
	
		if(window.WebSocket){
			socket = new WebSocket("ws://localhost:8080/websocket");
			socket.onmessage=function(event){
				var ta = document.getElementById("responseText");
				ta.value="";
				ta.value=event.data;
			};
			
			socket.onopen = function(event){
				var ta = document.getElementById("responseText");
				ta.value="";
				ta.value="WebSocket close";
			};
		}else{
			alert("sorry,your browser does not support WebSocket");
		}
		
		function send(message){
			if(!window.WebSocket){
				return;
			}
			if(socket.readyState == WebSocket.OPEN){
				socket.send(message);
			}else{
				alert("WebSocket connect successfully")
			}
		}
	</script>
	
	<form onsubmit="return false;">
		<input type="text" name="message" value="Netty best priactive"/>
		<br><br>
		<input type="button" value="send WebSocket message" onclick="send(this.form.message.value)">
		<hr color="blue"/>
		<h3>server response</h3>
		<textarea id="responseText" style="width:500px;height:300px;"></textarea>
	</form>
</body>
</html>